package com.suke.czx.modules.contact.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.suke.czx.common.utils.R;
import com.suke.czx.modules.contact.entity.Contact;
import com.suke.czx.modules.contact.mapper.ContactMapper;
import com.suke.czx.modules.contact.service.ContactService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 应用模块名称: 联系人
 * 代码描述: 联系人业务层
 * copyright: AUZAR ALL RIGHTS RESERVED
 * company: AUZAR
 *
 * @author: 颜米晨
 * @date: 2021/09/01 14:47:07
 */
@Service
@AllArgsConstructor
public class ContactServiceImpl extends ServiceImpl<ContactMapper, Contact> implements ContactService {

    private final ContactMapper contactMapper;

    /**
     * 删除联系人
     * @param contactId 联系人编码
     * @param userId 操作者编码
     * @return VO
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R updateDelContact(Long contactId, Long userId) {
        contactMapper.updateDelContact(contactId, userId);
        return R.ok();
    }

    /**
     * 根据客户或供应商删除所有联系人
     * @param type 联系人类型
     * @param relationId 关系编码
     * @param userId 操作者编码
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateDelContactByRelation(Integer type, Long relationId, Long userId) {
        contactMapper.updateDelContactByRelation(type, relationId, userId);
    }

}
